<template>
    <h3>理财项目</h3>
    理财项目名称
    <input type="text" v-model="Sharinfo.SName">
    理财收益
    <input type="text" v-model="Sharinfo.MinPrice">-
    <input type="text" v-model="Sharinfo.MaxPrice">
    <input type="button" value="搜索" @click="Show">

    <table border="1">
        <tr>
            <td>理财编号</td>
            <td>登录用户名</td>
            <td>理财项目名称</td>
            <td>理财收益</td>
            <td>操作</td>
        </tr>

        <tr v-for="item in info">
            <td>{{item.Sid}}</td>
            <td>{{item.SName}}</td>
            <td>{{item.SPrice}}</td>
            <td>{{item.SUName}}</td>
            <td>
                <a href="#" @click="BuyMoneyInfo(item.Sid)">我要购买</a>
            </td>
        </tr>
    </table>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue'
import axios from 'axios';
import { useRouter } from 'vue-router';

const router=useRouter()

const Sharinfo = ref({
    SName: '',
    MinPrice:'',
    MaxPrice:''
})

const info=ref([{
    Sid: 0,
    SName: '',
    SPrice: '',
    SUName: ''
}])

onMounted(()=>{
   Show()
})


//显示
const Show=()=>{
    axios.get("http://localhost:8177/api/Money/ShowInfo",{
        params:{
            SName:Sharinfo.value.SName,
            MinPrice:Sharinfo.value.MinPrice,
            MaxPrice:Sharinfo.value.MaxPrice
        }
    })
    .then(res=>{
        info.value=res.data 
    })
}

const BuyMoneyInfo=(Sid:number)=>{
    // location.href="/BuyMoney"
    router.push({
        name:"BuyMoney",
        params:{
            Sid:Sid
        }
    })
}

</script>